window.initializeSortable = (elementId) => {
  const el = document.getElementById(elementId);
  if (el) {
    new Sortable(el, {
      animation: 150, // 设置拖动动画时间
      onEnd: (evt) => {
        const sortedItems = Array.from(el.children).map(item => item.innerText);
        window.dispatchEvent(new CustomEvent('tagsSorted', { detail: sortedItems }));
      }
    });
  }
};
